

pub fn parse_size(s: &str) -> usize {
    let mut index = 0;
    let buf = s.as_bytes();
    let mut value = 0;
    while index < buf.len() {
        let v = buf[index];
        if (v >= b'0') && (v <= b'9') {
            value = value * 10 + ((v - b'0') as usize);
        } else if v == b'k' || v == b'K' {
            value = value * 1024;
            break;
        } else {
            panic!("invalid size")
        }
        index += 1;
    }

    value
}
